import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';
import 'package:lib_uikit/widgets/chart/chart_line_widget.dart';

import 'chart_xy_value_utils.dart';
import 'model/chart_dot_data.dart';
import 'model/chart_xy_data.dart';

/// @Title   两色折线图组件，没有手势交互，有填充色
/// @Author: bryce
/// @CreateDate:  2023/8/16 15:18
class ChartTwoColorsLineWidget extends StatelessWidget {
  final List<ChartDotData> dots;
  final double height;
  final double? width;
  final Color topColor;
  final Color bottomColor;
  final double barWidth;
  final double rightPadding;

  /// 是否展示上下填充色,
  final bool showAboveBellowAreaColor;

  /// 防止弯曲的时候越界(默认为true,不建议修改，除非有特殊需求需要展示大平滑度)
  final bool preventCurveOverShooting;

  /// 曲线平滑度值，默认0.35，当isCurve为true时才有效
  final double curveSmoothness;

  /// 折线是否弯曲
  final bool isCurved;

  const ChartTwoColorsLineWidget({
    super.key,
    required this.dots,
    required this.topColor,
    required this.bottomColor,
    this.showAboveBellowAreaColor = true,
    this.barWidth = 2,
    this.width,
    this.height = 300,
    this.rightPadding = 10,
    this.preventCurveOverShooting = true,
    this.curveSmoothness = 0.35,
    this.isCurved = true,
  });

  @override
  Widget build(BuildContext context) {
    return ChartLineWidget(
        dots: dots,
        height: height,
        width: width,
        barWidth: barWidth,
        topColor: topColor,
        bottomColor: bottomColor,
        enableTouch: false,
        showLeftTitle: false,
        showBottomTitle: false,
        showGridLine: false,
        showBottomBorder: false,
        isCurved: isCurved,
        rightPadding: rightPadding,
        preventCurveOverShooting: preventCurveOverShooting,
        curveSmoothness: curveSmoothness,
        showAboveBellowAreaColor: showAboveBellowAreaColor);
  }
}
